package com.shopreg.dao;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.HibernateException;
import org.hibernate.SessionException;

import com.shopreg.entity.ShopDetails;
import com.shopreg.hibernate.util.BaseHibernateDAO;
import com.shopreg.util.ShopRegUtil;

public class ShopRegDAOImpl extends BaseHibernateDAO implements ShopRegDAO {
	private static final Log log = LogFactory.getLog(ShopRegDAOImpl.class);
	@Override
	public void saveShopDetails(ShopDetails shopDetails) {

		ShopRegUtil shopUtil = new ShopRegUtil();
		boolean paramsGood = shopUtil.checkShopDetailParams(shopDetails);
		if(paramsGood){
			try{
			log.debug("Saving ShopDetails instance");
			getSession().save(shopDetails);
			getTransaction().commit();
			}
			catch (HibernateException e) {
				log.debug("Saving Failed");
				e.printStackTrace();
			}
			finally{
				try{
				getSession().close();
				}
				catch (SessionException e) {
					e.printStackTrace();
					}
				}
			}
	}

	
	
}
